home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-21 | 1.6 KB | 73 lines | [TEXT/CWIE] |
- #include "newmain.h"
- #include <devices.h>
-
- static UInt8 Decimal2BCD(UInt8 n) {
- return ((n / 10) << 4) + (n % 10);
- }
-
- static void Long2BCD(long blks, UInt8 *bcd) {
- long minutes, seconds, frames;
-
- blks += 150;
-
- minutes = blks / 4500L;
- blks -= minutes * 4500L;
- seconds = blks / 75L;
- frames = blks - (seconds * 75);
-
- *bcd++ = Decimal2BCD((UInt8) minutes);
- *bcd++ = Decimal2BCD((UInt8) seconds);
- *bcd = Decimal2BCD((UInt8) frames);
- }
-
- static void Initialize(void){
- /* Initialize all the needed managers. */
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
- }
-
- static void clearmem(Ptr p,long l){
- for (long a = 0;a<l;a++){
- (p)[a] = 0;
- }
- }
-
- static OSErr AudioPlayTrack(short refNum,short track,Boolean isStopAddress){
-
- struct tAudioPlayParam {
- short addressType;
- UInt8 address[4];
- short isStopAddress;
- short playMode;
- };
-
- CntrlParam cntrlParam;
- tAudioPlayParam &audioPlayParam = *(tAudioPlayParam *) cntrlParam.csParam;
-
- clearmem(Ptr(&cntrlParam), sizeof(CntrlParam));
-
- audioPlayParam.addressType = TRACKADDR;
- audioPlayParam.address[3] = track;
- audioPlayParam.isStopAddress = isStopAddress ? 1 : 0;
- audioPlayParam.playMode = 9; // Stereo
-
- cntrlParam.ioCRefNum = refNum;
- cntrlParam.csCode = csAPlay; // csAudioPlay
-
- OSErr err = PBControlSync((ParamBlockRec *) &cntrlParam);
-
- return err;
- }
-
- void PlayTrack(short track){
- short myRefNum;
- OSErr myErr = OpenDriver("\p.AppleCD", &myRefNum);
- myErr = AudioPlayTrack(myRefNum,track+1,true);
- myErr = AudioPlayTrack(myRefNum,track,false);
- }
-